<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用长度属性length来计算字符串的长度</title>
</head>

<body>
    <script>
        var txt = "Hello World!";
        document.write("<p>" + txt.length + "</p>");
        var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        document.write("<p>" + txt.length + "</p>")
    </script>
</body>

</html>